#pragma 

namespace gtl
{

class jobj
{
public:
	jobj()
	{
	}

public:
	template<class T>
	jobj& field(const gtl::tchar* name, T val)
	{
		if(name == NULL)
			return;

		m_obj << _T("\"") << name << _T("\":") << _T("\"") << val << _T("\"");
		return *this;
	}

	template<class T>
	jobj& field(const gtl::tchar* name, std::vector<T> val)
	{
		if(name == NULL)
			return;

		m_obj << _T("\"") << name << _T("\":") << _T("[");
		array(val);
		m_obj << _T("]");
		return *this;
	}

	template<class T>
	jobj& array(const std::vector<T>& val)
	{
		m_obj += _T("[");
		for(size_t i = 0; i < val.size(); ++i)
		{
			if(i > 0)
				m_obj += _T(",");

			m_obj << _T("'") << val[i] << _T("'");
		}
		m_obj += _T("]");

		return *this;
	}

public:
	operator const gtl::tstr&()
	{
		return m_obj;
	}

protected:
	gtl::tstr m_obj;
};

} // end of namespace gtl